<?php
    define("APP", TRUE);
    require('modules/loader.php');
	
	if(!isset($_GET['id'])){
		header('location:index.php');
		return FALSE;
	}
	$id = intval($_GET['id']);
	
	$sql = "SELECT * FROM gallery AS g JOIN category AS c ON g.category=c.cid WHERE g.id='$id'";
	$gallery = $db->query($sql)->result_array();
	if(empty($gallery)){
		header('location:index.php');
		return FALSE;
	}
	$pic = $db->query("SELECT * FROM pics where gid='".$gallery[0]['id']."'")->result_array();
	
	$data = array();
	$data['gallery'] = $gallery[0];
	$data['pic']     = $pic;
    $v->load('header');
	$v->load('meinu', $data);
?>